package cn.cxy.customviewdemos

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView

class UnderlineTextView(context: Context, attrs: AttributeSet?) :
    AppCompatTextView(context, attrs) {
    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        val paint = Paint()
        paint.color = Color.BLUE
        paint.strokeWidth = 5f
        val width = width
        val height = baseline
        canvas.drawLine(0f, height.toFloat() + 10, width.toFloat(), height.toFloat() + 10, paint)
    }
}